package com.dream.springmvc.filter.operators;

import lombok.Getter;

import java.time.LocalDateTime;

/**
 * @author panwen
 */

@Getter
public enum DatetimeOperator {
    eq(Operators::eqOp),
    ne(Operators::neOp),
    gt(Operators::gtOp),
    gte(Operators::gteOp),
    lt(Operators::ltOp),
    lte(Operators::lteOp),
    range(null);

    private final OpFunc<LocalDateTime> opf;
    private final RangeOpFunc<LocalDateTime> rangeOpf;

    DatetimeOperator(OpFunc<LocalDateTime> opf) {
        this.opf = opf;
        this.rangeOpf = (start, end, value) ->
                value.isAfter(start) && value.isBefore(end) ||
                        value.equals(start) || value.equals(end);
    }
}
